using System;
using System.Collections.Generic;
using System.Text;
using PerfilEmpreendedor.Bo.Model;
using PerfilEmpreendedor.Dao.Interfaces;
using NHibernate;
using NHibernate.Criterion;

namespace PerfilEmpreendedor.Dao.Implements
{
    public class HistoricoDao:HibernateDao<Historico>,IHistoricoDao
    {

        public Historico ObterUltimaJogada(int idPartida)
        {
            ICriteria query = session.CreateCriteria<Historico>();
            query.CreateAlias("Partida", "part");
            query.Add(Restrictions.Eq("part.Id", idPartida));
            query.AddOrder(new Order("DataPergunta", false));
            if (query.List().Count > 0)
            {
                return query.List<Historico>()[0];
            }
            else
            {
                return null;
            }
        }
    }
}
